<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class login extends CI_Controller {

function __construct() {
        parent::__construct();
    }

	function index()
	{
		if($this->session->userdata("logged_in")=="")
		{
            $d['title']= "APLIKASI STOCKIS";
 			$this->load->view("v_login",$d);
		}
		else
		{
			redirect("home");
		}
	}

	function cek_user()
	{
		if($this->session->userdata("logged_in")=="")
		{
 			$dt['id_user'] = $_POST['username'];
 			$dt['password'] = $_POST['password'];
			$this->m_login->cekUserLogin($dt);
		}
		else
		{
			redirect("home");
		}
	}

        function logout()
	{
		if($this->session->userdata("logged_in")!="")
		{
			$this->session->sess_destroy();
			redirect("home");
		}
		else
		{
			redirect("login");
		}
	}
}
